<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/style.css" />
		<style>
			.mui-input-row label {
				font-family: 'Helvetica Neue', Helvetica, sans-serif;
				line-height: 1.1;
				float: left;
				width: 35%;
				padding: 11px 5px;
				font-size: 14px;
				color: #666;
			}
			
			.mui-btn {
				border: 1px solid #25CDDA;
				width: 300px;
				background-color: #25CDDA;
			}
			
			.mui-btn:active {
				border: 1px solid #58dde8!important;
				background-color: #58dde8!important;
			}
			
			.mui-bar-nav {
				background: #27CDDB;
			}
			
			.mui-action-back,
			.mui-title,
			.mui-action-back:active {
				color: #FFFFFF;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="title">微信绑定</h1>
		</header>
		<div class="mui-content">
			<p style="margin: 10px;">
				**请务必填写本人真实信息，随意填写信息或盗用他人信息，一经发现直接封号。
			</p>
			<div id="oldpass_div" class="mui-input-row" style="background: white;margin-top: 5px;margin-left: 5px;margin-right: 5px;">
				<label>微信账号：</label>
				<input id="weixinInput" type="text" class="mui-input-clear" placeholder="请输入微信账号">
			</div>

			<div class="mui-button-row" style="margin-bottom: 20px;margin-top: 10px;">
				<button type="button" class="mui-btn mui-btn-primary" id="confirm">确认提交</button>&nbsp;&nbsp;
			</div>
		</div>

		<script src="../js/mui.min.js "></script>
		<script type="text/javascript" src="../js/public.js"></script>
		<script type="text/javascript ">
			mui.init();
			var member = null;
			mui.plusReady(function() {
				swipeBack();
				member = JSON.parse(plus.storage.getItem("member"));
				document.getElementById("weixinInput").value = member.wechat;
			})

			document.getElementById('confirm').addEventListener('tap', function() {
				var weixinInput = document.getElementById('weixinInput');
				var weixin = weixinInput.value;

				//验证密码
				if(!weixin) {
					mymui("请输入微信账号");
					return;
				}
				commitWeixin(weixin);
			});

			//修改密码
			function commitWeixin(weixin) {
				mui.postJSON(ModifyAlipay, {
					"wechat": weixin
				}, function(data) {
					mConsole.log("修改微信信息:" + JSON.stringify(data));
					var code = data.code;
					if(code == 0) {
						// 显示自动消失的提示消息
						plus.nativeUI.toast("微信绑定成功");
						member.wechat = weixin;
						plus.storage.setItem("member", JSON.stringify(member));
						openSetting();
					} else {
						mymui(data.msg);
					}
				});
			}

			function openSetting() {
				//触发详情页面的setUserState事件
				mui.fire(plus.webview.getWebviewById('setting'), 'setUserState', {});
				//打开
				mui.back();
			}
		</script>
	</body>

</html>